/*
 * Copyright the original author or authors.
 * 
 * Licensed under the MOZILLA PUBLIC LICENSE, Version 1.1 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *	  http://www.mozilla.org/MPL/MPL-1.1.html
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.googlecode.milib.display {
	import com.googlecode.milib.base.MLBroadcastClass;

	import flash.display.DisplayObjectContainer;
	import flash.display.MovieClip;
	import flash.utils.getQualifiedClassName;

	/**
	 * @author Marek Brun
	 */
	public class MCDuplicatorSimple extends MLBroadcastClass {				private var duplicatedMC:MovieClip;
		private var dupliationsCount:Number=0;
		private var mc_parent:DisplayObjectContainer;

		public function MCDuplicatorSimple(duplicatedMC:MovieClip, parent:DisplayObjectContainer=null) {			this.duplicatedMC=duplicatedMC;
			mc_parent=parent;		}				public function getNewMC(addToParent:Boolean=false):MovieClip {			dupliationsCount++;			var mcClass:Class=Class(duplicatedMC.constructor);
			if(getQualifiedClassName(mcClass)=="flash.display::MovieClip"){
				throw new Error("Please create class name for that instance ("+duplicatedMC.parent.name+'.'+duplicatedMC.name+")");
			}
			var newMC:MovieClip=MovieClip(new mcClass());
			newMC.name=duplicatedMC.name+'Copy'+dupliationsCount;
			if(addToParent){
				mc_parent.addChild(newMC);
			}
			return newMC;		}			}}